﻿using System.Collections.Generic;

namespace TimerTask.Common.Utils
{
    public static class DicExtension
    {
        /// <summary>
        /// 将dic[str,str]转为string
        /// author:肖阳
        /// 2016-09-24 18:36:57
        /// </summary>
        /// <param name="dic"></param>
        /// <returns></returns>
        public static string ToStr(this IDictionary<string, string> dic)
        {
            string result = string.Empty;
            List<string> items = new List<string>();
            if (dic != null)
            {
                foreach (var kv in dic)
                {
                    items.Add(string.Format("{0}={1}", kv.Key, kv.Value));
                }
                result = string.Join("&", items);
            }
            return result;
        }
    }
}
